package com.zj.ibasetest;

import android.util.Log;

import com.alibaba.fastjson.JSON;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by zhaojie on 2018/4/9.
 */

public class TestTools {

    //3des加密后参数的key
    public static final String THE_3DES_ENCRYPT_NAME = "ciphertext";

    public final static <T> Map<String, String> getEncryptParams(String key, T value) {
        Map<String, T> param = new HashMap<>();
        param.put(key, value);
        return getEncryptParams(param);
    }

    public final static <T> Map<String, String> getEncryptParams(Map<String, T> param) {
        String jp = JSON.toJSONString(param);
        String encryptParam = "";
        try {
            encryptParam = ThreeDesutil.encryptThreeDESECB(jp, ThreeDesutil.KEY);
        } catch (Exception e) {
            e.printStackTrace();
            Log.e("erro", "  Encrypt is not work ,your connection has maybe more out of service : show detail _ ThreeDesutil.class");
        }
        Map<String, String> map = new HashMap<>();
        map.put(THE_3DES_ENCRYPT_NAME, (encryptParam.replaceAll("\n", "").trim()));
        return map;
    }
}
